#include "GameSound.h"

#define NUM_SOUNDS 5

string soundNames[NUM_SOUNDS] = {
	"../../Sounds/14615__man__canon.wav",
	"../../Sounds/36847__ecodtr__laserrocket2.wav",
	"../../Sounds/56900__syna-max__war.wav",
	"../../Sounds/75190__herbertboland__sheeheep.wav",
	"../../Sounds/41579__erdie__steps-on-stone01.wav"	//Don't forget to uncomment the comma!
//	"../../Sounds/139320__votives__arpegthing.ogg",
//	"../../Sounds/142010__vosvoy__the-road-a-melody-from-the-past.ogg"
};

GameSound::GameSound(CameraNode* cam)
{
	camera = cam;
	shape = new OBJMesh("../../Meshes/ico.obj");
	SoundSystem::GetSoundSystem()->SetListener(camera);
	for(int i = 0; i < NUM_SOUNDS; ++i) {
		Sound::AddSound(soundNames[i]);
	}
}


GameSound::~GameSound(void)
{
	delete shape;
}

void GameSound::GenerateSound()
{
	for(int i = 0; i < 5; ++i) {
		SoundNode* s = new SoundNode();
		//Add a random sound
		s->SetSound(Sound::GetSound(soundNames[i]));
		s->SetLooping(true); //Make sound loop forever

		s->SetMesh(shape); //We want to be able to see it!
		s->SetColour(Vector4(1,1,1,0.2)); //Make node transparent, too

		//Make each node have a slightly random size.
		s->SetModelScale(Vector3(400,400,400));
		s->SetRadius(400);
		s->SetBoundingRadius(400);

		
		//And a random position, too
		Vector3 randpos = Vector3(i*500-1000,200,0);
	
		s->SetTransform(Matrix4::Translation(randpos));

		//Add the node into the graph - They'll add themselves to the
		//SoundSystem when they get Updated
		Renderer::GetRenderer().AddNode(s);
	}
}